//
//  ViewController.swift
//  Demo-11 识别摇晃手势
//
//  Created by quanhao huang on 2019/10/14.
//  Copyright © 2019 demo. All rights reserved.
//

import UIKit

class ViewController: UIViewController {
    
    @IBOutlet weak var shakingLb: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }

    override func motionBegan(_ motion: UIEvent.EventSubtype, with event: UIEvent?) {
        self.shakingLb.isHidden = false
    }
    
    override func motionEnded(_ motion: UIEvent.EventSubtype, with event: UIEvent?) {
        DispatchQueue.main.asyncAfter(deadline:.now() + 1.0) {
            self.shakingLb.isHidden = true
        }
    }
    
    override func becomeFirstResponder() -> Bool {
        return true
    }

}

